window.onload=function(){
		var log = document.getElementById("order");
		log.onclick=function(){
			var tel = $("#tel").val();
    		var password = $("#password").val();
    		var password2 = $("#password2").val();
			var tasty = $('#tasty').val();
			var type_of_cooking =$('#type_of_cooking').val();
			var hometown = $('#hometown').val();
			
			if(!/^[0-9]{11}$/.test(tel)) alert("手机号输入不正确，请重新输入");
			if(password.length<6) alert("密码过于短请重新输入");
			if(password!==password2) alert("两次输入的密码不同，请重新输入");
			if((password.length>=6)&&(password===password2)&&/^[0-9]{11}$/.test(tel))
			{				
						var postData = {
							"submit":"马上注册",
							"tel": tel,
							"password": password,
							"confirm":password2,
							"type_of_cooking":type_of_cooking,
							"tasty":tasty,
							"hometown":hometown 	
						}
						console.log(postData);
						$.post('http://118.89.25.120/register.php', postData, function (data) {
							var obj  = JSON.parse(data.trim());
							console.log(typeof obj);
							console.log(obj);
							
							if(obj.success==1)  {
								alert("注册成功");
								window.location="enter.html";
							} else if (obj.success==0) {
								alert("用户信息不完整");
							} else if (obj.success==-1) {
								alert("该手机号已被注册");
							}else if(obj.success==-3){
								alert("系统忙碌，请重试");
							}
						});
				/*$.ajax({
					type:"post",
					url:"http://118.89.25.120/login.php",
					async:true,
					dataType:"json",
					data:{submit:"马上注册",tel:tel,password:password,taste:taste,like:like,hometown:hometown},
					success:function(e){
			 		window.location.href="prompt.html";
					},
					error:function(e){
						alert("连接服务器错误。检查网络");
					}
				});*/
			}
			
			
		}
}